package com.example.math_exam.MVC;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView( getLayoutID());

        initActivity();
        setOperation();
        setListener();
    }

    protected abstract int getLayoutID();

    protected abstract void initActivity();

    protected abstract void setOperation();

    protected abstract void setListener();

    protected <T extends View>T f( int id) {
        T t = findViewById(id);
        return t;
    }

    protected void startClass( Class c) {
        startActivity( new Intent(this, c));
    }

    protected void startClassFinish( Class c) {
        startActivity( new Intent(this, c));
        finish();
    }

    protected void startClass( Intent intent) {
        startActivity( intent);
    }

    protected void startClassFinish( Intent intent) {
        startActivity( intent);
        finish();
    }
}
